package com.zztl.infiniteBand.presenter

import android.content.Context

import com.zztl.infiniteBand.base.BasePresenter
import com.zztl.infiniteBand.model.TradingRecordBean
import com.zztl.infiniteBand.net.FilterSubscriber
import com.zztl.infiniteBand.net.RetorfitServiceManger
import com.zztl.infiniteBand.net.converter.DataConverter
import com.zztl.infiniteBand.net.requestBean.TradingRecordRequest
import com.zztl.infiniteBand.ui.view.mvpview.RecordView


/**
 * @desc
 * @auth ${user}
 * @time 2018/6/13  20:01
 */
class RecordPresennter : BasePresenter<RecordView>() {

    fun getRecordData(recordRequest: TradingRecordRequest, context: Context) {
        addSubscribe(RetorfitServiceManger
                .observe(RetorfitServiceManger.instance!!.apiService
                .getTransactionRecord(DataConverter.instance.toJson(recordRequest)))
                .subscribe(object : FilterSubscriber<TradingRecordBean>(context) {
                    override fun success(tradingRecordBean: TradingRecordBean) {
                        view!!.getDeviceSuccessOrFail()
                        view!!.getRecordDataSuccess(tradingRecordBean)
                    }

                    override fun fail() {
                        super.fail()
                        view!!.getDeviceSuccessOrFail()
                    }
                }))
    }

}
